package com.mine.androidlearn.common.base;


import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.mine.androidlearn.GlobalApplication;

/**
 * 普通Activity的基类
 *
 * @author mine
 * @version V1.0 2018/8/5 15:59
 */
public abstract class BaseActivity extends AppCompatActivity {

    protected GlobalApplication mGlobalApplication; // application

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mGlobalApplication = (GlobalApplication) getApplication();

        initVariables();
        initViews(savedInstanceState);
        loadData();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        // 加入内存泄漏监视队列
        GlobalApplication.getRefWatcher().watch(this);
    }

    /**
     * 初始化变量
     */
    protected abstract void initVariables();

    /**
     * 初始化视图
     *
     * @param savedInstanceState
     */
    protected abstract void initViews(Bundle savedInstanceState);

    /**
     * 加载数据
     */
    protected abstract void loadData();
}
